package demo.demo07.test02;

public class testLambda {
    //3.静态内部类
    static class Like2 implements ILike {
        @Override
        public void Lambda() {
            System.out.println("2");
        }
    }

    public static void main(String[] args) {
        ILike like = new Like1();
        like.Lambda();

        like = new Like2();
        like.Lambda();

        //4.局部内部类
        class Like3 implements ILike {
            @Override
            public void Lambda() {
                System.out.println("3");
            }
        }
        like = new Like3();
        like.Lambda();

        //5.匿名内部类，没有类的名称必须借助接口或者父类
        like = new ILike() {
            @Override
            public void Lambda() {
                System.out.println("4");
            }
        };
        like.Lambda();

        //6.Lambda表达式简化
        like = () -> {
            System.out.println("5");
        };
        like.Lambda();
    }

    //1.定义一个函数式接口
    interface ILike {
        void Lambda();
    }
}

//2.实现类
class Like1 implements testLambda.ILike {
    @Override
    public void Lambda() {
        System.out.println("1");
    }
}